From 07dd5f8c73504359d9b6b1f1d52db1196fecbf9b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 20 Jul 2026 17:21:56 +0000 Subject: [PATCH] Add an AGGRESSION_EVENT_LOG update trigger to keep the ID from changing --- db/schemas/lib/triggers/Makefile | 1 + .../triggers/create/aggression_event_log.m4 | 49 +++++++++++++++++++ .../lib/triggers/drop/aggression_event_log.m4 | 23 +++++++++ 3 files changed, 73 insertions(+) create mode 100644 db/schemas/lib/triggers/create/aggression_event_log.m4 create mode 100644 db/schemas/lib/triggers/drop/aggression_event_log.m4 diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 1c601a1..660c3c7 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -56,6 +56,7 @@ ORDER := comm_ids \ elo_ranks_daily_kk_m \ elo_ranks_daily_mt_f \ elo_ranks_daily_mt_m \ + aggression_event_log \ chimps_on_tikis DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/aggression_event_log.m4 b/db/schemas/lib/triggers/create/aggression_event_log.m4 new file mode 100644 index 0000000..a08b4c5 --- /dev/null +++ b/db/schemas/lib/triggers/create/aggression_event_log.m4 @@ -0,0 +1,49 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the aggression_event_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'aggression_event_log_update_func'; +CREATE OR REPLACE FUNCTION aggression_event_log_update_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for aggression_event_log update trigger + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + cannot_change(`AGGRESSION_EVENT_LOG', `ID') + + RETURN NULL; + END; +$$; + + +RAISE INFO 'aggression_event_log_update_trigger'; +CREATE TRIGGER aggression_event_log_update_trigger + AFTER INSERT OR UPDATE + ON aggression_event_log FOR EACH ROW + EXECUTE PROCEDURE aggression_event_log_update_func(); diff --git a/db/schemas/lib/triggers/drop/aggression_event_log.m4 b/db/schemas/lib/triggers/drop/aggression_event_log.m4 new file mode 100644 index 0000000..27629ff --- /dev/null +++ b/db/schemas/lib/triggers/drop/aggression_event_log.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for aggression_event_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS aggression_event_log_update_func() CASCADE; -- 2.34.1